import React from 'react';
import {useEffect, useState} from "react";
import {useHistory} from 'umi'

export default function Nowplaying() {

  const [list,setlist] = useState([])

  const history = useHistory()

  useEffect(() => {
      fetch("https://m.maizuo.com/gateway?cityId=440100&pageNum=1&pageSize=10&type=1&k=5792864",{
        headers: {
          'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.0","e":"1640782700594797135921153","bc":"440100"}',
          'X-Host': 'mall.film-ticket.film.list'
        }
      }).then(res => res.json())
        .then(res => {
          console.log(res.data.films)
          setlist(res.data.films)
        })
  },[])

  return (
    <div>
      正在热映
      <ul>
        {list.map((item:any) =>
          <li key={item.filmId} onClick={() => {
            history.push(`/detail/${item.filmId}`)
          }}>{item.name}</li>
        )}
      </ul>
    </div>
  )
}
